home *** CD-ROM | disk | FTP | other *** search
- Path: news-m01.ny.us.ibm.net!usenet
- From: schlaep@ibm.net (Patrick Schlaepfer)
- Newsgroups: comp.lang.c++
- Subject: VC++4.0 & SQL
- Date: Thu, 15 Feb 1996 21:25:16 GMT
- Message-ID: <4g06hg$4beo@news-s01.ny.us.ibm.net>
- NNTP-Posting-Host: slip139-92-42-176.ut.nl.ibm.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- Source code of the SQL testprogram, copied
- from the MS Visual C++ CD.
-
- Error Message I get:
-
- --------------------Configuration: Text1 - Win32
- Debug--------------------
- Compiling...
- Text1.cpp
- C:\home\patrick\msdv\simple_odbc\Text1.cpp(26) : error C2664:
- 'SQLConnect' :
- cannot convert parameter 2 from 'char [8]' to 'unsigned char *' (new
- behavior; please see help)
- Error executing cl.exe.
- Text1.obj - 1 error(s), 0 warning(s)
-
- What can I do to connect the database?
- Any suggestions.
-
- Programname: Text1.cpp
-
- #include <windows.h>
- #include <sql.h>
- #include <sqlext.h>
- #include <string.h>
-
- void main()
- {
- HENV henv;
- HDBC hdbc;
- HSTMT hstmt;
- RETCODE retcode;
-
- retcode = SQLAllocEnv(&henv); /* Environment handle */
- if (retcode == SQL_SUCCESS) {
- retcode = SQLAllocConnect(henv, &hdbc); /* Connection handle */
- if (retcode == SQL_SUCCESS) {
-
- /* Set login timeout to 5 seconds. */
-
- SQLSetConnectOption(hdbc, SQL_LOGIN_TIMEOUT, 5);
-
- /* Connect to data source */
-
- retcode = SQLConnect(hdbc, "EmpData", SQL_NTS,
- "JohnS", SQL_NTS,
- "Sesame", SQL_NTS);
-
- if (retcode == SQL_SUCCESS || retcode ==
- SQL_SUCCESS_WITH_INFO){
-
- /* Process data after successful connection */
-
- retcode = SQLAllocStmt(hdbc, &hstmt); /* Statement
- handle */
- if (retcode == SQL_SUCCESS) {
- MessageBox(NULL, "Successfully
- completed.","Success", MB_OK);
- SQLFreeStmt(hstmt, SQL_DROP);
- }
- SQLDisconnect(hdbc);
- }
- SQLFreeConnect(hdbc);
- }
- SQLFreeEnv(henv);
- }
- }
-
-
- Regards Pat
- ------------------------------------------------
- _/ _/ _/_/_/ Patrick Schlaepfer
- _/_/ _/ _/ Schulstrasse 12
- _/ _/_/ _/ CH-89262 Bergdietikon
- _/ _/ _/ does it! patrick@schlaepferag.ch
-
-
-